package com.yanqu.road.server.gameplayer.module.assistant;

import com.yanqu.road.entity.assistant.AssistantBodySkin;
import com.yanqu.road.entity.assistant.UserAssistantDecoration;
import com.yanqu.road.entity.assistant.UserAssistantSuit;
import com.yanqu.road.entity.config.patrons.CombInfo;
import com.yanqu.road.entity.config.skin.SkinInfo;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.log.LogAssistantSkinUpgrade;
import com.yanqu.road.entity.player.UserBeauty;
import com.yanqu.road.logic.bussiness.player.UserAssistantSkinBusiness;
import com.yanqu.road.pb.assistant.AssistantSkinProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.gameplayer.module.patrons.PatronsModule;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.skin.SkinModule;
import com.yanqu.road.server.manger.assistant.AssistantSkinMgr;
import com.yanqu.road.server.manger.config.SkillMgr;
import com.yanqu.road.server.manger.config.SkinMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.rank.RankMgr;
import com.yanqu.road.server.pb.AssistantSkinPb;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import static com.yanqu.road.entity.enums.eItemId.*;

/**
 * 小助理换装模块
 */
public class AssistantSkinModule extends GeneralModule {

    private AssistantBodySkin assistantBodySkin;                //小助理当前身上皮肤
    private Map<Integer, UserAssistantSuit> assistantSuitMap;           //小助理拥有套装等级<套装ID,套装>
    private Map<Integer, UserAssistantDecoration> assistantDecorationMap;           //小助理拥有皮肤<皮肤ID,皮肤>

    public AssistantSkinModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean loadData() {
        assistantBodySkin = UserAssistantSkinBusiness.getUserAssistantBodySkin(player.getUserId());
        assistantSuitMap = UserAssistantSkinBusiness.getAssistantSuitMap(player.getUserId());
        assistantDecorationMap = UserAssistantSkinBusiness.getAssistantSkinMap(player.getUserId());
        if (assistantBodySkin == null && SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            initUserData();
        }
        initDefaultSuitOrDecoration();
        checkDressValue();
        return true;
    }

    @Override
    public boolean afterLoadData() {
        return false;
    }

    @Override
    public boolean saveData() {
        if (assistantBodySkin != null) {
            if (assistantBodySkin.isInsertOption()) {
                UserAssistantSkinBusiness.addUserAssistantBodySkin(assistantBodySkin);
            } else if (assistantBodySkin.isUpdateOption()) {
                UserAssistantSkinBusiness.updateUserAssistantBodySkin(assistantBodySkin);
            }
        }

        for (UserAssistantSuit userAssistantSuit : assistantSuitMap.values()) {
            if (userAssistantSuit.isInsertOption()) {
                UserAssistantSkinBusiness.addAssistantSuit(userAssistantSuit);
            } else if (userAssistantSuit.isUpdateOption()) {
                UserAssistantSkinBusiness.updateAssistantSuit(userAssistantSuit);
            }
        }
        for (UserAssistantDecoration userAssistantDecoration : assistantDecorationMap.values()) {
            if (userAssistantDecoration.isInsertOption()) {
                UserAssistantSkinBusiness.addAssistantSkin(userAssistantDecoration);
            } else if (userAssistantDecoration.isUpdateOption()) {
                UserAssistantSkinBusiness.updateAssistantSkin(userAssistantDecoration);
            }
        }
        return true;
    }

    @Override
    public void loginSendMsg() {
        syncUserData();
    }

    @Override
    public void afterLogin() {

    }

    /**
     * 初始化用户
     */
    private void initUserData() {
        if (assistantBodySkin != null) {
            return;
        }
        //初始化小助理身上的装扮
        AssistantBodySkin tmpAssistantBodySkin = new AssistantBodySkin();
        tmpAssistantBodySkin.setUserId(player.getUserId());
        tmpAssistantBodySkin.setCharacterId(0);     //角色 暂时没用
        tmpAssistantBodySkin.setHeadId(ASSISTANT_DEFAULT_HEAD_DECORATION.getValue());         //头
        tmpAssistantBodySkin.setFaceId(ASSISTANT_DEFAULT_FACE_DECORATION.getValue());         //脸
        tmpAssistantBodySkin.setClothesId(ASSISTANT_DEFAULT_CLOTHES_DECORATION.getValue());      //衣服
        tmpAssistantBodySkin.setPantsId(ASSISTANT_DEFAULT_PANTS_DECORATION.getValue());        //裤子
        tmpAssistantBodySkin.setFootId(ASSISTANT_DEFAULT_FOOT_DECORATION.getValue());         //足部
        tmpAssistantBodySkin.setHandId(ASSISTANT_DEFAULT_HAND_DECORATION.getValue());         //手部
        tmpAssistantBodySkin.setOtherId(ASSISTANT_DEFAULT_OTHER_DECORATION.getValue());        //挂饰
        tmpAssistantBodySkin.setInsertOption();
        assistantBodySkin = tmpAssistantBodySkin;

    }

    /**
     * 更换小助理皮肤
     */
    public int changeAssistantBodySkin(AssistantBodySkin changeSkin) {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            return GameErrorCode.E_ASSISTANT_SKIN_SYSTEM_NO_UNLOCK;
        }
        AssistantSkinProto.AssistantChangeSkinRespMsg.Builder builder = AssistantSkinProto.AssistantChangeSkinRespMsg.newBuilder();
        builder.setRet(0);
        //分部位穿上衣服,穿不上的传回客户端
        if (!changeDecoration(changeSkin.getHeadId(), eAssistantDecorationType.Head.getValue())) {
            builder.addLackDecorations(changeSkin.getHeadId());
        }
        if (!changeDecoration(changeSkin.getFaceId(), eAssistantDecorationType.Face.getValue())) {
            builder.addLackDecorations(changeSkin.getFaceId());
        }
        if (!changeDecoration(changeSkin.getClothesId(), eAssistantDecorationType.Clothes.getValue())) {
            builder.addLackDecorations(changeSkin.getClothesId());
        }
        if (!changeDecoration(changeSkin.getPantsId(), eAssistantDecorationType.Pants.getValue())) {
            builder.addLackDecorations(changeSkin.getPantsId());
        }
        if (!changeDecoration(changeSkin.getFootId(), eAssistantDecorationType.Foot.getValue())) {
            builder.addLackDecorations(changeSkin.getFootId());
        }
        if (!changeDecoration(changeSkin.getHandId(), eAssistantDecorationType.Hand.getValue())) {
            builder.addLackDecorations(changeSkin.getHandId());
        }
        if (!changeDecoration(changeSkin.getOtherId(), eAssistantDecorationType.Other.getValue())) {
            builder.addLackDecorations(changeSkin.getOtherId());
        }
        //换装后服装
        builder.setNowDecoration(AssistantSkinPb.parseAssistantBodyDecorationsMsg(assistantBodySkin));
        //排行榜上参数替换一下
        RankMgr.changeUserRank(eBigRankType.Normal.getValue(), player.getUserId(), BigInteger.valueOf(getTotalDressValue()), eRankType.AssistantDressOnValue.getValue(), getCollocationString());
        player.sendPacket(ClientProtocol.U_ASSISTANT_CHANGESKIN_RESULT, builder);
        return 0;
    }


    /**
     * 小助理套装升级
     */
    public int upgradeAssistantSuit(int suitId) {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            return GameErrorCode.E_ASSISTANT_SKIN_SYSTEM_NO_UNLOCK;
        }
        CombInfo combInfo = AssistantSkinMgr.getAssistantSuitCombInfo(suitId);
        //判断组合是否存在
        if (combInfo == null) {
            return GameErrorCode.E_ASSISTANT_SUIT_NO_EXIST;
        }
        //判断技能配置,目前只有一种限制，套装等级不能高于套装内任何部件的强化等级.
        if (SkillMgr.getSkillInfo(combInfo.getCombSkillId()) == null){
            log.error("skills info error ,skillId = {}", combInfo.getCombSkillId());
            return GameErrorCode.E_ASSISTANT_SUIT_NO_FINISH;
        }
        if (SkillMgr.getSkillInfo(combInfo.getCombSkillId()).getMaxLevel() != -4) {
            log.error("skills info error ,skillId = {}", combInfo.getCombSkillId());
            return GameErrorCode.E_ASSISTANT_SUIT_NO_FINISH;
        }

        //拿出用户套装信息
        UserAssistantSuit userAssistantSuit = assistantSuitMap.get(suitId);
        int mostLowLevel = Integer.MAX_VALUE;
        for (int decorationId : combInfo.getObjectIdList()) {               //根据comb中皮肤id寻找解锁的装扮
            UserAssistantDecoration userAssistantDecoration = assistantDecorationMap.get(decorationId);
            if (null == userAssistantDecoration) {              //没有解锁该装扮
                return GameErrorCode.E_ASSISTANT_SUIT_NO_FINISH;
            }
            if (userAssistantDecoration.getDecorationLevel() < mostLowLevel) {      //找到套装内等级最低的
                mostLowLevel = userAssistantDecoration.getDecorationLevel();
            }
        }
        if (userAssistantSuit != null) {
            //有其中多于一个皮肤不满足条件(单个装扮比升级后套装等级低)
            if (mostLowLevel <= userAssistantSuit.getSuitLevel()) {
                return GameErrorCode.E_ASSISTANT_SUIT_NO_FINISH;
            }
            //升级
            userAssistantSuit.setSuitLevel(userAssistantSuit.getSuitLevel() + 1);
            userAssistantSuit.setUpdateOption();
        } else {
            if (mostLowLevel <= 0) {
                return GameErrorCode.E_ASSISTANT_SUIT_NO_FINISH;
            }
            userAssistantSuit = new UserAssistantSuit();
            userAssistantSuit.setUserId(player.getUserId());
            userAssistantSuit.setSuitId(suitId);
            userAssistantSuit.setSuitLevel(1);
            assistantSuitMap.put(suitId, userAssistantSuit);
            userAssistantSuit.setInsertOption();
        }
        //日志
        AutoLogMgr.add(new LogAssistantSkinUpgrade(player.getUserId(), 2, userAssistantSuit.getSuitId(), userAssistantSuit.getSuitLevel()));
        //门客资质变化
        player.getModule(PatronsModule.class).onPatronsChange(null);
        //返回消息
        AssistantSkinProto.AssistantUpgradeSuitRespMsg.Builder builder = AssistantSkinProto.AssistantUpgradeSuitRespMsg.newBuilder();
        builder.setRet(0);
        builder.setUpgradeResult(AssistantSkinPb.parseAssistantSuitMsg(userAssistantSuit));
        player.sendPacket(ClientProtocol.U_ASSISTANT_UPGRADE_SUIT_RESULT, builder);
        return 0;
    }

    /**
     * 获取最高盛装值的几个装扮
     */
    public List<UserAssistantDecoration> getTopDecorationList(int topNum) {
        List<UserAssistantDecoration> copyDecorationList = new ArrayList<>(assistantDecorationMap.values());
        if (copyDecorationList.isEmpty()) {
            return copyDecorationList;
        }
        copyDecorationList.sort(Comparator.comparingLong(UserAssistantDecoration::getDressScore).reversed());
        if (copyDecorationList.size() < topNum) {
            topNum = copyDecorationList.size();   //不足3的取实际大小
        }
        copyDecorationList = copyDecorationList.subList(0, topNum);
        return copyDecorationList;
    }

    /**
     * 升级或者解锁一下小助理皮肤
     */
    public int upgradeAssistantDecoration(int decorationId) {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            return GameErrorCode.E_ASSISTANT_SKIN_SYSTEM_NO_UNLOCK;
        }
        //用户拥有装扮
        UserAssistantDecoration userAssistantDecoration;
        //拿出装扮配置
        SkinInfo skinInfo = SkinMgr.getSkinInfo(decorationId);
        if (skinInfo == null || skinInfo.getType() != eSkinType.Assistant.getValue()) {
            log.error("skinInfo is null,skinId: {}", decorationId);
            return GameErrorCode.E_ASSISTANT_SKIN_NO_EXIST;
        }
        //消耗道具
        String cost = String.format("%d=%d", decorationId, 1);
        Property property = PropertyHelper.parseStringToProperty(cost);
        if (!player.getModule(CurrencyModule.class).removeCurrency(property, eLogMoneyType.Skin, eLogMoneyType.AssistantUpgradeCost)) {
            return GameErrorCode.E_ASSISTANT_SKIN_ITEM_NO_ENOUGH;
        }
        AssistantSkinProto.AssistantUpgradeDecorationRespMsg.Builder builder = AssistantSkinProto.AssistantUpgradeDecorationRespMsg.newBuilder();
        if (!assistantDecorationMap.containsKey(decorationId)) {        //解锁装扮
            userAssistantDecoration = new UserAssistantDecoration();
            userAssistantDecoration.setUserId(player.getUserId());
            userAssistantDecoration.setDecorationId(decorationId);
            userAssistantDecoration.setDecorationLevel(1);
            userAssistantDecoration.setDressScore(skinInfo.getUnlockGet());
            userAssistantDecoration.setInsertOption();
            assistantDecorationMap.put(decorationId, userAssistantDecoration);
        } else {
            userAssistantDecoration = assistantDecorationMap.get(decorationId);             //升级装扮
            userAssistantDecoration.setDecorationLevel(userAssistantDecoration.getDecorationLevel() + 1);
            userAssistantDecoration.setDressScore(skinInfo.getUnlockGet() + skinInfo.getUpgradeGet() * (userAssistantDecoration.getDecorationLevel() - 1));
            userAssistantDecoration.setUpdateOption();
        }
        //日志
        AutoLogMgr.add(new LogAssistantSkinUpgrade(player.getUserId(), 1, userAssistantDecoration.getDecorationId(), userAssistantDecoration.getDecorationLevel()));
        //重新计算魅力及亲密度
        syncBeautyEffectData();
        //重新计算排行
        RankMgr.changeUserRank(eBigRankType.Normal.getValue(), player.getUserId(), BigInteger.valueOf(getTotalDressValue()), eRankType.AssistantDressOnValue.getValue(), getCollocationString());
        //返回消息
        builder.setRet(0);
        builder.setUpgradeResult(AssistantSkinPb.parseAssistantDecorationsMsg(userAssistantDecoration));
        player.sendPacket(ClientProtocol.U_ASSISTANT_UPGRADE_DECORATION_RESULT, builder);
        return 0;
    }

    /**
     * 同步小助理皮肤效果加成
     */

    private void syncBeautyEffectData() {
        BeautyModule beautyModule = player.getModule(BeautyModule.class);
        for (UserBeauty userBeauty : beautyModule.getBeautyMap().values()) {
            player.getModule(SkinModule.class).recaclBeautyAttr(userBeauty, false);
        }
        beautyModule.syncUserBeauty(new ArrayList<>(beautyModule.getBeautyMap().values()), false);
    }


    /**
     * 算总的盛装值
     */
    public long getTotalDressValue() {
        Map<Integer, UserAssistantDecoration> copyMap = new ConcurrentHashMap<>(assistantDecorationMap);
        long result = 0;
        if (copyMap.isEmpty()) {
            return result;
        }
        for (int key : copyMap.keySet()) {
            if (null != copyMap.get(key)) {
                result += copyMap.get(key).getDressScore();
            }
        }
        return result;
    }

    /**
     * 重新计算盛装值 (只在加载用户信息时调用一次)
     */
    private long checkDressValue() {
        long result = 0;
        if (assistantSuitMap.isEmpty()) {
            return result;
        }
        for (int key : assistantDecorationMap.keySet()) {
            UserAssistantDecoration decoration = assistantDecorationMap.get(key);
            long dressOnValue;
            SkinInfo skinInfo = SkinMgr.getSkinInfo(decoration.getDecorationId());
            if (null == skinInfo) {
                log.error("skin info error at {}", key);
                continue;
            }
            if (decoration.getDecorationLevel() == 1) {
                dressOnValue = skinInfo.getUnlockGet();
            } else if (decoration.getDecorationLevel() > 1) {
                dressOnValue = skinInfo.getUnlockGet() + (decoration.getDecorationLevel() - 1) * skinInfo.getUpgradeGet();
            } else {
                dressOnValue = 0;
            }
            decoration.setDressScore(dressOnValue);
            result += dressOnValue;
        }
        RankMgr.changeUserRank(eBigRankType.Normal.getValue(), player.getUserId(), BigInteger.valueOf(result), eRankType.AssistantDressOnValue.getValue(), getCollocationString());
        return result;
    }

    /**
     * 获得当前搭配字符串  排行榜,送财使用 取不到返回所有小助理服装默认值
     */
    public String getCollocationString() {
        String string;
        if (null == assistantBodySkin) {
            string = String.format("%d;%d;%d;%d;%d;%d;%d", ASSISTANT_DEFAULT_HEAD_DECORATION.getValue(), ASSISTANT_DEFAULT_FACE_DECORATION.getValue(), ASSISTANT_DEFAULT_CLOTHES_DECORATION.getValue(), ASSISTANT_DEFAULT_PANTS_DECORATION.getValue(), ASSISTANT_DEFAULT_FOOT_DECORATION.getValue(), ASSISTANT_DEFAULT_HAND_DECORATION.getValue(), ASSISTANT_DEFAULT_OTHER_DECORATION.getValue());
        } else {
            string = String.format("%d;%d;%d;%d;%d;%d;%d", assistantBodySkin.getHeadId(), assistantBodySkin.getFaceId(), assistantBodySkin.getClothesId(), assistantBodySkin.getPantsId(), assistantBodySkin.getFootId(), assistantBodySkin.getHandId(), assistantBodySkin.getOtherId());
        }
        return string;
    }

    /**
     * 各部位换装
     */
    private boolean changeDecoration(int decorationId, int decorationType) {
        //拿出小助理更换部位的所有皮肤
        if (SkinMgr.getAssistantPartDecorationMap().get(decorationType) == null) {                  //判断配置是否正确
            log.error("Assistant decoration Info error,decorationType={},decorationId={}", decorationId, decorationType);
            return false;
        }
        boolean isDefaultDecoration = isDefaultDecoration(decorationId);                                                //判断是否为默认皮肤

        //判断是否为该部位皮肤，防止传错部位
        if (!SkinMgr.getAssistantPartDecorationMap().get(decorationType).containsKey(decorationId) && !isDefaultDecoration) {
            return false;
        }
        if (!assistantDecorationMap.containsKey(decorationId) && !isDefaultDecoration) {        //判断自己有没有皮肤
            return false;
        }
        //穿上皮肤
        return putOnSkinByType(decorationId, decorationType);
    }

    /**
     *  根据部位穿皮肤
     */
    private boolean putOnSkinByType(int decorationId, int decorationType) {
        if (decorationType == eAssistantDecorationType.Head.getValue()) {
            assistantBodySkin.setHeadId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Face.getValue()) {
            assistantBodySkin.setFaceId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Clothes.getValue()) {
            assistantBodySkin.setClothesId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Pants.getValue()) {
            assistantBodySkin.setPantsId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Foot.getValue()) {
            assistantBodySkin.setFootId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Hand.getValue()) {
            assistantBodySkin.setHandId(decorationId);
            return true;
        }
        if (decorationType == eAssistantDecorationType.Other.getValue()) {
            assistantBodySkin.setOtherId(decorationId);
            return true;
        }
        return false;
    }

    /**
     * 同步用户信息
     */
    private void syncUserData() {
        if (null == assistantBodySkin) {
            return;
        }
        AssistantSkinProto.SyncAssistantAllDecoration.Builder builder = AssistantSkinProto.SyncAssistantAllDecoration.newBuilder();
        for (UserAssistantDecoration decoration : assistantDecorationMap.values()) {
            builder.addDecorations(AssistantSkinPb.parseAssistantDecorationsMsg(decoration));                           //拥有装扮信息
        }
        for (UserAssistantSuit suit : assistantSuitMap.values()) {
            builder.addSuits(AssistantSkinPb.parseAssistantSuitMsg(suit));                                              //拥有套装信息
        }
        builder.setBodyDecoration(AssistantSkinPb.parseAssistantBodyDecorationsMsg(assistantBodySkin));                 //穿着皮肤
        player.sendPacket(ClientProtocol.U_SYNC_ASSISTANT_BODY_SKIN, builder);
    }

    /**
     * 判断是否是默认皮肤
     */
    private boolean isDefaultDecoration(int decorationId) {
        return decorationId == ASSISTANT_DEFAULT_CLOTHES_DECORATION.getValue() || decorationId == ASSISTANT_DEFAULT_FACE_DECORATION.getValue()
                || decorationId == ASSISTANT_DEFAULT_FOOT_DECORATION.getValue() || decorationId == ASSISTANT_DEFAULT_HAND_DECORATION.getValue()
                || decorationId == ASSISTANT_DEFAULT_PANTS_DECORATION.getValue() || decorationId == ASSISTANT_DEFAULT_OTHER_DECORATION.getValue()
                || decorationId == ASSISTANT_DEFAULT_HEAD_DECORATION.getValue();
    }

    public void initSystem() {
        initUserData();
        initDefaultSuitOrDecoration();
        syncUserData();
    }

    public AssistantBodySkin getAssistantBodySkin() {
        return assistantBodySkin;
    }

    public void setAssistantBodySkin(AssistantBodySkin assistantBodySkin) {
        this.assistantBodySkin = assistantBodySkin;
    }

    public Map<Integer, UserAssistantSuit> getAssistantSuitMap() {
        return assistantSuitMap;
    }

    public Map<Integer, UserAssistantDecoration> getAssistantDecorationMap() {
        return assistantDecorationMap;
    }

    /**
     * 更换小助理皮肤
     */
    public int changeAssistantDesktop(int desktopId) {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            return GameErrorCode.E_ASSISTANT_SKIN_SYSTEM_NO_UNLOCK;
        }
        AssistantSkinProto.AssistantChangeDesktopRespMsg.Builder respMsg = AssistantSkinProto.AssistantChangeDesktopRespMsg.newBuilder();
        //拿出用户套装信息
        UserAssistantSuit userAssistantSuit = assistantSuitMap.get(desktopId);
        if(null == userAssistantSuit){
            return GameErrorCode.E_ASSISTANT_SUIT_NO_EXIST;
        }
        if(userAssistantSuit.getSuitLevel() < 1){
            return GameErrorCode.E_ASSISTANT_SUIT_NO_EXIST;
        }

        assistantBodySkin.setDesktopId(desktopId);
        respMsg.setRet(0);
        respMsg.setDesktopId(desktopId);
        player.sendPacket(ClientProtocol.U_ASSISTANT_CHANGE_DESKTOP, respMsg);
        return 0;
    }

    /**
    * 描述：初始化原皮套装
    * 作者：zrq
    * 时间：2022/12/12
    * 参数：

    * 返回值：
    **/
    private void initDefaultSuitOrDecoration() {
        if (!SystemOpenMgr.systemOpen(player, eSystemId.Assistant.getValue())) {
            return;
        }
        int suitId = ASSISTANT_DEFAULT_SUIT.getValue();
        if(!assistantSuitMap.containsKey(suitId)){
            UserAssistantSuit data = new UserAssistantSuit();
            data.setUserId(player.getUserId());
            data.setSuitId(suitId);
            data.setSuitLevel(1);
            data.setInsertOption();
            assistantSuitMap.put(suitId, data);
        }

        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_HEAD_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_FACE_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_CLOTHES_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_PANTS_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_FOOT_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_HAND_DECORATION.getValue());
        initDefaultAssistantDecoration(ASSISTANT_DEFAULT_OTHER_DECORATION.getValue());
    }

    /**
    * 描述：初始化默认配件
    * 作者：zrq
    * 时间：2022/12/12
    * 参数：

    * 返回值：
    **/
    private void initDefaultAssistantDecoration(int decorationId){
        if(assistantDecorationMap.containsKey(decorationId)){
            return;
        }
        UserAssistantDecoration data = new UserAssistantDecoration();
        data.setUserId(player.getUserId());
        data.setDecorationId(decorationId);
        data.setDecorationLevel(1);
        long dressScore = 0;
        SkinInfo skinInfo = SkinMgr.getSkinInfo(decorationId);
        if(null != skinInfo){
            dressScore = skinInfo.getUnlockGet();
        }
        data.setDressScore(dressScore);
        data.setInsertOption();
        assistantDecorationMap.put(decorationId, data);
    }
}
